package rest

import (
	"fmt"
	"github.com/lishimeng/go-log"
	"net/url"
)

func (rc *RestClient) preExec() (requestUri string, err error) {
	log.Debug("path:", rc.path)
	requestUri, err = url.JoinPath(rc.host, rc.path...) // 拼接uri
	if len(rc.query) > 0 {                              // 拼接query部分
		var content = ""
		for key, value := range rc.query {
			content = content + fmt.Sprintf("%s=%s&", key, value)
		}
		requestUri = fmt.Sprintf("%s?%s", requestUri, content)
	}
	if DebugEnable {
		log.Debug("request: %s", requestUri)
	}
	return
}
